<!--
 * Created by PhpStorm.
 * User: jackhhy
 * Date: 2019/7/4-14:39
 * Link: https://gitee.com/luckygyl/lucky_admin
 * FileName: email.html
 *-->

{include file="public/head" /}

<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">邮件设置</div>
                <div class="layui-card-body" pad15>

                    <div class="layui-form" lay-filter="" id="form">
                        <div class="layui-form-item">
                            <label class="layui-form-label">发件箱</label>
                            <div class="layui-input-inline">
                                <input name="email[from_email]" type="text"  lay-vertype="tips" lay-verify="email" autocomplete="off" class="layui-input" value="{$info->from_email}">
                            </div>
                            <div class="layui-form-mid layui-word-aux">发送邮件的邮箱地址</div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">发件人</label>
                            <div class="layui-input-inline">
                                <input name="email[from_name]"  autocomplete="off" class="layui-input" type="text" value="{$info->from_name}">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">smtp服务器</label>
                            <div class="layui-input-inline">
                                <input name="email[smtp]" type="text" lay-verify="pass" lay-vertype="tips" autocomplete="off" class="layui-input" value="{$info->smtp}">
                            </div>
                            <div class="layui-form-mid layui-word-aux">如：smtp.126.com</div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">账号</label>
                            <div class="layui-input-inline">
                                <input name="email[username]" type="text" lay-verify="email"  lay-vertype="tips" autocomplete="off" autocomplete="off" class="layui-input" value="{$info->username}">
                            </div>
                            <div class="layui-form-mid layui-word-aux">发送邮件的邮箱账户</div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="email[password]" lay-vertype="tips"  autocomplete="off" class="layui-input" value="{$info->password}">
                            </div>
                            <div class="layui-form-mid layui-word-aux">发送邮件的邮箱密码</div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">邮件标题</label>
                            <div class="layui-input-block"  style="max-width: 400px">
                                <input name="email[title]" lay-verify="require" autocomplete="off" lay-vertype="tips"  class="layui-input" type="text" value="{$info->title}">
                            </div>
                        </div>
                        {:token()}
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">邮件模板</label>
                            <div class="layui-input-block" style="max-width:800px;">
                                <textarea placeholder="请输入内容" class="layui-textarea" name="email[content]" lay-verify="content1" id="LAY_demo1" >{$info->content}</textarea>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="setmyinfo">确认修改</button>
                                &nbsp;&nbsp;
                                <button class="layui-btn layui-btn-normal" id="mailto" >发送测试</button>
                            </div>
                        </div>

                    </div>

                </div>
            </div>
        </div>
    </div>
</div>


<script src="{__FRAME_PATH}js/function.js"></script>

<script >

    layui.use(['element','form', 'jquery', 'layedit','util','upload'], function () {
        var element = layui.element;
        var form = layui.form;
        var $ = layui.jquery;
        var layedit = layui.layedit;
        var util=layui.util;
        var upload=layui.upload;

        form.render();

        //自定义工具栏
        var demo1s= layedit.build('LAY_demo1', {
            tool:["strong","italic","underline","del","|","left","center","right","|","link","unlink","face"]
            ,height: 190
        });

        //自定义验证规则
        form.verify({
            content1:function (value) {
                layedit.sync(demo1s);
            }

        });

        /**
         *邮件测试
         */
       $("#mailto").click(function () {
           layer.prompt({
               formType: 0,
               value: '',
               title: '请输入邮箱地址,不要重复点确定键'
           }, function(value, index, elem){
               email = value;
               $.ajax({
                   url:"{:url('admin/setting/mailto')}"
                   ,type:'post'
                   ,data:{email:email}
                   ,beforeSend:function(){
                           layer.load(2);
                   }
                   ,success:function(res) {
                       layer.msg(res.msg,{time:1500});
                       if(res.code == 1) {
                           layer.close(index);
                       }
                   },
                   complete:function(){
                       layer.closeAll('loading');
                   }
               })
           });
           return false;
       });



        /**
         * 表格提交
         */
        form.on('submit(setmyinfo)', function (data) {
            FormSubmit("{:url('admin/setting/email')}",data.field);
            return false;
        });


    });

</script >

</body >
</html>